package cn.bdqn.demo.service;

import cn.bdqn.demo.bean.Order;
import cn.bdqn.demo.dao.OrderDao;
import cn.bdqn.demo.ex.ServiceException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrderService {
    @Resource
    OrderDao orderDao;

    public void add(Order order) throws ServiceException {
        try {
            orderDao.save(order);
        } catch (Throwable e) {
            throw new ServiceException(e);
        }
    }
    public int getCount() throws ServiceException {
        int count = 0;
        try {
            count = orderDao.count();
        } catch (Throwable e) {
            throw new ServiceException(e);
        }
        return count;
    }
}
